//
//  HttpRequestV2.h
//  LimitFreeMaster
//
//  Created by tanghaibo on 12-12-18.
//  last Modified by zhangtie  13-11-19
//
//  2013.3.22 增加对文件的上传支持 by tanghaibo
//

#import "ASIFormDataRequest.h"
#import "QBHttpRequestHeader.h"
#define kNotiSessionTimeout     @"kNotiSessionTimeout"

#define KEY_ERRORMSG            @"errorMsg"
#define KEY_RETURNDATA          @"data"
#define FAILDMESSAGE            @"网络异常"

typedef enum HttpMethod{
    HttpMethodGet,
    HttpMethodPost,
    HttpMethodDelete,
    HttpMethodunPostAndDelete, //带json的delete
}HttpMethod;

#if NS_BLOCKS_AVAILABLE
//typedef void (^ASIRequsetBlock)(ASIHTTPRequest *request);
@class QBHttpRequest;
typedef void (^ASIRequsetBlock)(QBHttpRequest *request, NSDictionary *resultDic);
#endif

@interface QBHttpRequest : ASIFormDataRequest
{
    //带ASIHttprequest对象的block
	ASIRequsetBlock _completionReqBlock;
    
    ASIRequsetBlock _successReqBlock;
    
	ASIRequsetBlock _failureReqBlock;
}


+ (QBHttpRequest *)requestWithURLStr:(NSString *)initURLString
                               param:(NSDictionary *)param
                          httpMethod:(HttpMethod)httpMethod
                              isAsyn:(BOOL)isAsyn
                     completionBlock:(ASIRequsetBlock)aCompletionReqBlock
                         failedBlock:(ASIRequsetBlock)aFailedReqBlock;

+ (QBHttpRequest *)requestWithURLStr:(NSString *)initURLString
                               param:(NSDictionary *)param
                          httpMethod:(HttpMethod)httpMethod
                              isAsyn:(BOOL)isAsyn
                            postJson:(BOOL)postJson
                     completionBlock:(ASIRequsetBlock)aCompletionBlock
                         failedBlock:(ASIRequsetBlock)aFailedBlock;

//添加successBlock add By zt 2013.11.19
+ (QBHttpRequest*)requestWithURLStr:(NSString *)initURLString
                              param:(NSDictionary *)param
                         httpMethod:(HttpMethod)httpMethod
                             isAsyn:(BOOL)isAsyn
                       successBlock:(ASIRequsetBlock)aSuccessBlock
                        failedBlock:(ASIRequsetBlock)aFailedBlock;

+ (QBHttpRequest*)requestWithURLStr:(NSString *)initURLString
                              param:(NSDictionary *)param
                         httpMethod:(HttpMethod)httpMethod
                             isAsyn:(BOOL)isAsyn
                           userInfo:(NSDictionary*)userInfo
                       successBlock:(ASIRequsetBlock)sucessReqBlock
                        failedBlock:(ASIRequsetBlock)aFailedReqBlock;

+ (QBHttpRequest*)requestWithURLStr:(NSString *)initURLString
                              param:(NSDictionary *)param
                         httpMethod:(HttpMethod)httpMethod
                             isAsyn:(BOOL)isAsyn
                           userInfo:(NSDictionary*)userInfo
                       successBlock:(ASIRequsetBlock)sucessReqBlock
                        failedBlock:(ASIRequsetBlock)aFailedReqBlock
                    completionBlock:(ASIRequsetBlock)aCompletionBlock;


//增加超时时间
+ (QBHttpRequest*)requestWithURLStr:(NSString *)initURLString
                              param:(NSDictionary *)param
                         httpMethod:(HttpMethod)httpMethod
                            timeOut:(NSTimeInterval)timeOut
                             isAsyn:(BOOL)isAsyn
                           userInfo:(NSDictionary*)userInfo
                       successBlock:(ASIRequsetBlock)sucessReqBlock
                        failedBlock:(ASIRequsetBlock)aFailedReqBlock
                    completionBlock:(ASIRequsetBlock)aCompletionBlock;

+ (QBHttpRequest*)requestWithURLStr:(NSString *)initURLString
                              param:(NSDictionary *)param
                         httpMethod:(HttpMethod)httpMethod
                            timeOut:(NSTimeInterval)timeOut
                             isAsyn:(BOOL)isAsyn
                           postJson:(BOOL)postJons
                           userInfo:(NSDictionary*)userInfo
                       successBlock:(ASIRequsetBlock)sucessReqBlock
                        failedBlock:(ASIRequsetBlock)aFailedReqBlock
                    completionBlock:(ASIRequsetBlock)aCompletionBlock;

+ (NSDictionary *)commonParams;

#if NS_BLOCKS_AVAILABLE
- (void)setCompletionReqBlock:(ASIRequsetBlock)aCompletionBlock;
- (void)setFailedReqBlock:(ASIRequsetBlock)aFailedBlock;
- (void)setSuccessReqBlock:(ASIRequsetBlock)aSuccessBlock;
#endif

@end
